package test.meituan;

import java.util.Scanner;

/**
 * @Description
 * @Author Firenut
 * @Date 2023-08-19 00:28
 */
public class T2 {
    // 思路，从结点的两边进行查找，取小值
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case

            int n = in.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < n; i++) {
                nums[i] = in.nextInt();
            }

            int x = in.nextInt();
            int y = in.nextInt();
            x = x - 1;
            y = y - 1;

            int t = x;
            int sum1 = 0;
            // 先计算顺时针方向
            while (t != y) {
                sum1 += nums[t];
                t = (t + 1) % nums.length;
            }

            // 计算逆时针方向
            int sum2 = 0;
            t = x - 1 < 0 ? nums.length - 1 : x - 1;
            while (t != y) {
                sum2 += nums[t];
                t = t - 1 < 0 ? nums.length - 1 : t - 1;
            }
            sum2 += nums[t];


            System.out.println(Math.min(sum1, sum2));
        }
    }
}
